﻿<%@page import="com.hh.bss.util.StringHelper" %>
<%
  String contractId=request.getParameter("contractId");  
  String type=request.getParameter("type"); 
  
  if (StringHelper.isEmpty(contractId)) contractId="0";
  
%> 

	
<!DOCTYPE html>  
<html>  
<head>  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
    <meta name="keywords" content="客户合同">  
    <meta name="description" content="客户合同">  
    <title>客户合同</title>  
    
    <%@ include file="/WEB-INF/inc/default.jsp"%>
    <jsp:include page="/WEB-INF/inc/dic.jsp"/>

</head>  
<body>  
    
      
    
    <!-- edit form窗体（开始） -->  
    <div class="easyui-panel"  style="width:900px">
    	 
    	
        <form id="fm" method="post" novalidate>  
        	  	  	 <input type="hidden" name="id" > 
        	  	  	 <input type="hidden" name="custId" > 
       <table cellSpacing=0 cellPadding=0 class="dv-table" style="width:100%;border:0px solid #ccc;padding:5px;margin-top:0px;">
            <tr>
              <td>合同编号<font color="red">*</font></td>
              <td><input name="nbr" class="easyui-box easyui-validatebox"  required="true"></td>
              <td>客户<font color="red">*</font></td>
              <td><input name="custName" required="true" readonly="true" class="easyui-box easyui-validatebox"  required="true"><a href="#" class="easyui-linkbutton" onclick="javascript:selectCustomerBd()">选择</a></td>
            </tr>
            <tr>
              <td>合同格式<font color="red">*</font></td>
              <td><input class="easyui-combobox"   name="contractStyle" style="width:200px;"  data-options="data:__getConstantCategory('ContractStyle'),valueField:'code', textField:'value', multiple:false,panelHeight:'auto',mode:'remote' "></td>
              <td>合同类型<font color="red">*</font></td>
              <td><input class="easyui-combobox"   name="contractType" style="width:200px;"  data-options="data:__getConstantCategory('ContractType'),valueField:'code', textField:'value', multiple:false,panelHeight:'auto',mode:'remote' "></td>
            </tr>
            <tr>
              <td>合同语种</td>
              <td><input class="easyui-combobox"   name="lang" style="width:200px;"  data-options="data:__getConstantCategory('ContractLang'),valueField:'code', textField:'value', multiple:false,panelHeight:'auto',mode:'remote' "></td>
              <td>合同费率<font color="red">*</font></td>
              <td><input name="arRate" class="easyui-box easyui-validatebox"  required="true"></td>
            </tr>
            <tr>
              <td>最低收费<font color="red">*</font></td>
              <td><input name="minAr" class="easyui-numberbox easyui-validatebox"  required="true"></td>
              <td>合同开始日期<font color="red">*</font></td>
              <td><input name="beginDString" data-options="formatter:formateDate"  class="easyui-datebox easyui-validatebox"  ></td>
            </tr>
            <tr>
              <td>合同结束日期<font color="red">*</font></td>
              <td><input name="endDString" data-options="formatter:formateDate"  class="easyui-datebox easyui-validatebox"  ></td>
              <td>付款期限(天)</td>
              <td><input name="arD" class="easyui-numberbox"></td>
            </tr>
            <tr>
              <td>预付款</td>
              <td><input name="preAr" class="easyui-numberbox"></td>
              <td>预付款期限</td>
              <td><input name="preArD" data-options="formatter:formateDate"  class="easyui-datebox"></td>
            </tr>
            <tr>
              <td>预付款单位</td>
              <td><input class="easyui-combobox"   name="preUnit" style="width:200px;"  data-options="data:__getConstantCategory('MoneyType'),valueField:'code', textField:'value', multiple:false,panelHeight:'auto',mode:'remote' "></td>
              <td>保证期(试用期)(月)</td>
              <td><input name="trialMonths" class="easyui-box"></td>
            </tr>
            <tr>
              <td>退款比例</td>
              <td><input name="refundRate" class="easyui-numberbox"></td>
              <td>滞纳金比例</td>
              <td><input name="delayRate" class="easyui-numberbox"></td>
            </tr>
            <tr>
              <td>其它特别条款</td>
              <td colspan=3><textarea name="searchLimit" style="width:700px;height:100px" ></textarea></td>
              
            </tr>
            <tr>
              <td>其它备注</td>
              <td colspan=3><textarea name="comment" style="width:700px;height:100px" ></textarea></td>              
            </tr>
            
            
            
       </table> 	  	  	 
	        		           		     
        </form>  
        <div id="dlg-buttons" style="text-align:center;padding:5px">  
          <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="save()">Save</a>  
          <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:closeWin()">关闭</a>  
        </div>
        
    </div>  
    <!-- edit form窗体（结束） -->  
   

    <script type="text/javascript">  
        var url="/customer/customerContract/save.do";
        <%if ("UPDATE".equals(type)) {%>
        	 url="/customer/customerContract/update.do";
        <%}%>
        
        var selectCustomerBdWin; 
        
        function setCustomerBd(customer){
                          $('#fm input[name="custName"]').attr("value",customer.name);
                          $('#fm input[name="custId"]').attr("value",customer.id);
        }
        function selectCustomerBd(){
        	           if (selectCustomerBdWin)
                            selectCustomerBdWin.window('open');
                        else selectCustomerBdWin = $.window({
		                 	   	title:"选择客户",
		                 	   	url:"/customer/customerBd/selectBdCustomerPage.do",
		                 	   	isIframe:true,
		                 	   	height:450,
		                 	   	width:1150,
		                 	   	modal:true,		      	   	
		                 	   	width:1100,
		                 	   	onComplete:function(jq,iframe){	
		                 	   		         	   		   	      	   		
		                 	   		   var fwindow = $.window.util.getFrameWindow(iframe);		      	   		
		                 	   		   var ijq = fwindow.jQuery;		
		                 	   		   var curWin=this;   
		                 	   		   
		                 	   		   var curWin=this;
					           
					                      fwindow.closeWin=function(){
					                      	   curWin.window('close');
					                      	  
				                        };
				                        
				                        fwindow.callback=curWin.openerWin.setCustomerBd;
				                        //fwindow.pcallback=curWin.openerWin.addCompanyDB;
		                 	   		   //alert(fwindow.pcallback2);
		                 	   	}
		                 	});
		                 	selectCustomerBdWin.openerWin=window;  
         }
         
        function add(){         	 
            $('#dlg').dialog('open').dialog('setTitle','新增客户合同');  
            $('#fm').form('clear');  
            url = '/customer/customerContract/save.do';  
        }  
        function edit(){  
            //var row = $('#dg').datagrid('getSelected');  
            var rows = $('#dg').datagrid('getSelections');
            if (!rows||rows.length==0){
            	 $.messager.alert('提示','请选择要修改的行','info');
            	 return;
            }
            if (!rows||rows.length>1){
            	 $.messager.alert('提示','不能选择多行','info');
            	 return;
            }
            if (rows){  
                $('#dlg').dialog('open').dialog('setTitle','修改客户合同');  
                //$('#fm').form('load',rows[0]);  
                $('#fm').form('load','/customer/customerContract/get.do?id='+rows[0].id);  
                url = '/customer/customerContract/update.do';
            }  
        }  
        function save(){          	   
        	  if (!$('#fm').form('validate')) return; 
        	  //合同格式
        	  //
            $('#fm').form('submit',{  
                url: url,  
                onSubmit: function(){  
                    return $(this).form('validate');  
                },  
                success: function(result){  
                    var result = eval('('+result+')');                      
                    if (result.success == true){  
                        //$.messager.alert('信息',result.msg,'info');  
                        //$('#dlg').dialog('close');      // close the dialog  
                        //$('#dg').datagrid('reload');    // reload the user data  
                          alert(result.msg);
                          if (refresh) refresh();
                          if (closeWin) closeWin();
                    } else {  
                        //$.messager.alert('错误',result.msg,'error');
                        alert(result.msg);
                    }  
                }  
            });  
        }  
        <%if ("UPDATE".equals(type)) {%>
        	 $('#fm').form('load','/customer/customerContract/get.do?id='+<%=contractId%>); 
        <%}%>
        
        
    </script>  
     
     

     
     
     
</body>  
</html>